Page({
  data:{
    isFinish:false
  },
  onLoad({ id}) {
    // 获取通行证
    this.getPassport(id)
  },
   // 倒计时结束时触发
   countDownFinish() {
    this.setData({
      isFinish: true
    })
  },
  async getPassport(id) {
    const {
      code,
      data
    } = await wx.http.get(`/visitor/${id}`)
    if (code !== 10000) return wx.utils.Toast()
    this.setData({
      ...data
    })
  },
  // 可以在用户点击按钮后触发 Page.onShareAppMessage 事件
  onShareAppMessage() {
    return {
      title: '查看通行证',
      path: '/visitor_pkg/pages/passport/index',
      imageUrl: 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png'
    }
  },
  // 点击保存图片
  async saveImg() {
    // 获取图片临时路径
    const {
      path
    } = await wx.getImageInfo({
      src: this.data.url
    })
    console.log(path);
    wx.saveImageToPhotosAlbum({
      filePath: path
    })
  }
})